The quantum-mechanical problems of electron scattering by an infinitely thin solenoid and by a half of an infinitely thin solenoid are examined from the viewpoint of constructing a self-adjoint Hamiltonian. It is demonstrated that in both problems there exist unique self-adjoint operators with a ``non-singular'' domain, that, due to physical reasons, are identified with the corresponding Hamiltonians. In the case of quantized values of magnetic flow along the solenoid, the electron does not experience any scattering by the string. It is shown that the scattering amplitude and wave function of an electron in the problem of scattering by an infinitely long solenoid of radius a in the limit a->0 turn into the corresponding expressions for the problem of an infinitely thin solenoid. In particular, at a quantized value of magnetic flow along the solenoid, scattering disappears at a->0.